package alpiv.trucks;

import java.util.Random;

public class Main
{
    static RoadMap roads = null;
    static Road startR;
    static Random rnd = new Random();
    
    private static void usage()
    {
        String[] scenarios = RoadMap.getScenarios();
        System.err.println("usage: <scenario> <#trucks>");
        System.err.println("possible scenarios are:");
        for (int i=0; i<scenarios.length; i++)
            System.err.println(scenarios[i]);
        System.exit(5);
    }

    /**
     * The main method for the demonstration run.
     * The first parameter must be the name of a supported road map scenario.
     */
    public static void main(String[] args)
    {
        

        // parse command line arguments
        if (args.length < 2)
        {
            usage();
        }

        // create the road map scenario to use

        Integer trucks = 0;
        try {
            roads = new RoadMap(args[0]);
            trucks = Integer.parseInt(args[1]);
        } catch(RuntimeException ex)
        {
            usage();
        }
		//Beetle beetle = new Beetle(startR, Road.NORTH);
		
        for(int i = 0; i < trucks; i++) { 
        	startR = roads.getStart(rnd.nextInt(roads.getStarts()));
			Beetle b = new Beetle(startR, Road.NORTH);
			b.setName("Beetle"+i);
			b.start();
//        	TruckThread tT = new TruckThread(roads);
//        	tT.setName("S"+i);
//        	tT.start();
        }
        
    }
}

